home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / commodity / exchangev200.lha / ExChange / Install / Source / Exchange.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-30  |  30.9 KB  |  1,034 lines

  1. /*
  2.  * MUI - Exchange V2.00
  3.  *
  4.  * © 1994-95 by Marc Schröer ; T.O.M. Software Wuppertal
  5.  *
  6.  * email: schroeer@dekanat.informatik.uni-dortmund.de
  7.  *        marc@tom.anubis.sub.de
  8.  *
  9.  * smail: Marc-Christian Schröer
  10.  *        Mählersbeck 120
  11.  *        D-42279 Wuppertal
  12.  *        Germany
  13.  *
  14.  *
  15.  * Date        Author    Comment
  16.  * -----------------------------------------------------------------------
  17.  * 20.11.1993    mcs    first Public-Release (V1.00)
  18.  * 30.11.1993    mcs    APPICON tooltype implemented
  19.  * 04.12.1993    mcs    more tooltypes, Remove All
  20.  * 23.12.1993    mcs    CxTranslate
  21.  * 17.02.1994    mcs    Bugs removed, adjusted to MUI 2.0 
  22.  * 03.02.1994    mcs    SAS/C-Version
  23.  * 08.05.1994    mcs    minor enhancements, multi-select
  24.  * 23.07.1994    mcs    new layout
  25.  * 29.01.1995    mcs    enhancements, MUI 2.3 adjustments
  26.  * 30.01.1995    mcs    second Public-Release / AmiNet (V2.00)
  27.  */
  28.  
  29. #include <clib/muimaster_protos.h>
  30. #include <clib/commodities_protos.h>
  31. #include <pragmas/muimaster_pragmas.h>
  32. #include <pragmas/commodities_pragmas.h>
  33. #include <libraries/mui.h>
  34. #include <libraries/commodities.h>
  35.  
  36. #include <Defines.h>        // some personal definitions
  37.  
  38. #include "Exchange_protos.h"    // machine-generated prototypes
  39.  
  40. #include "Comm.h"
  41. #include "Exchange_cat.h"    // localizing file
  42.  
  43. #define VERSION "2.00"        // global Version
  44.  
  45. // some enums for IDs
  46.  
  47. enum{ ID_ABOUT=1, ID_QUIT, ID_REMOVESEL, ID_ACTIVATESEL, ID_DEACTIVATESEL, ID_INTERFACESEL,
  48.       ID_SHOWSEL, ID_HIDESEL, ID_REMOVE, ID_TOGGLE, ID_INTERFACE, ID_SHOW,
  49.       ID_HIDE, ID_LV_ACTIVE, ID_ICONIFY, ID_HOTKEY, ID_DEACTIVATEALL, ID_ACTIVATEALL,
  50.       ID_MENUHELP, ID_REMOVEALL, ID_DOUBLE, ID_DEACTIVATE, ID_ACTIVATE };
  51.  
  52. // global variables
  53.  
  54. extern struct Catalog    *ExchangeCatalog;
  55.  
  56. struct Library        *MUIMasterBase;
  57. struct Library        *CxBase;
  58. struct IntuitionBase    *IntuitionBase;
  59. struct Library        *IconBase, *LocaleBase;
  60.  
  61. Object *AP_ExChange, *WN_Main, *LV_Broker, *FT_Info, *BT_Toggle, *BT_Remove,
  62.        *BT_Show, *BT_Hide, *BT_DeActAll, *BT_ActAll, *BT_Icon, *BT_Quit, *BT_RemoveAll,
  63.        *BT_ActSel, *BT_DeActSel, *BT_RemoveSel, *BT_ShowSel, *BT_HideSel,
  64.        *TX_Desc;
  65.  
  66. struct MsgPort        *TPort;
  67. struct timerequest    *TRequest;
  68. struct Message        *TMsg;
  69. ULONG  TSignal;
  70. UBYTE  **TTypes;
  71. BOOL   AppIcon = FALSE;
  72. BOOL   set_able = FALSE;
  73. char   *Pages[4];
  74. char   *CycleEntries[3];
  75.  
  76. __saveds __asm struct BrokerCopy *BrokerListConFunc(register __a0 struct Hook *hook, register __a2 APTR mem_pool, register __a1 struct BrokerCopy *b)
  77. {
  78.  struct BrokerCopy *bc;
  79.  
  80.  if(bc = AllocVec(sizeof(struct BrokerCopy), MEMF_ANY))
  81.   CopyMem(b, bc, sizeof(struct BrokerCopy));
  82.  
  83.  return(bc);
  84. }
  85.  
  86. __saveds __asm LONG BrokerListDesFunc(register __a0 struct Hook *hook, register __a2 APTR mem_pool, register __a1 struct BrokerCopy *bc)
  87. {
  88.  if(bc)
  89.   FreeVec(bc);
  90.  
  91.  return(0);
  92. }
  93.  
  94. __saveds __asm void BrokerListDspFunc(register __a0 struct Hook *hook, register __a2 char **array, register __a1 struct BrokerCopy *bc)
  95. {
  96.  static UBYTE active_str[20];
  97.  
  98.  if(bc)
  99.  {
  100.   *array++ = bc -> bc_Name;
  101.  
  102.   if(bc -> bc_Flags & COF_ACTIVE)
  103.    sprintf(active_str, "\0330%s", GetExchangeString(Active));
  104.   else
  105.    sprintf(active_str, "\0333%s", GetExchangeString(Inactive));
  106.  
  107.   *array = active_str;
  108.  }
  109.  else
  110.  {
  111.   *array++ = GetExchangeString(ColName);
  112.   *array++ = GetExchangeString(ColState);
  113.  }
  114. }
  115.  
  116. __saveds __asm LONG BrokerListCmpFunc(register __a0 struct Hook *hook, register __a2 struct BrokerCopy *bc1, register __a1 struct BrokerCopy *bc2)
  117. {
  118.  return(stricmp(bc2 -> bc_Name, bc1 -> bc_Name));
  119. }
  120.  
  121. __saveds __asm void BrokerListBrkFunc(register __a0 struct Hook *hook, register __a2 Object *obj, register __a1 CxMsg *cm)
  122. {
  123.  if((CxMsgType(cm) == CXM_COMMAND) && (CxMsgID(cm) == CXCMD_LIST_CHG))
  124.   RefreshBrokerList();
  125.  
  126.  if((CxMsgType(cm) == CXM_IEVENT) && (CxMsgID(cm) == ID_HOTKEY))
  127.  {
  128.   set(AP_ExChange, MUIA_Application_Iconified, FALSE);
  129.   set(WN_Main, MUIA_Window_Open, TRUE);
  130.  }
  131. }
  132.  
  133. __saveds __asm LONG SelectNameRXFunc(register __a0 struct Hook *hook, register __a2 Object *appl, register __a1 ULONG *arg)
  134. {
  135.  char *name;
  136.  
  137.  if(name = (char *)*arg)
  138.  {
  139.   ULONG pos;
  140.  
  141.   if(pos = FindBrokerName(name))
  142.   {
  143.    set(LV_Broker, MUIA_List_Active, pos);
  144.    DoMethod(LV_Broker, MUIM_List_Jump, pos);
  145.  
  146.    return(RETURN_OK);
  147.   }
  148.  }
  149.  return(RETURN_ERROR);
  150. }
  151.  
  152. __saveds __asm LONG SelectTaskRXFunc(register __a0 struct Hook *hook, register __a2 Object *appl, register __a1 ULONG *arg)
  153. {
  154.  ULONG task;
  155.  
  156.  if(task = *((ULONG *)*arg))
  157.  {
  158.   ULONG pos;
  159.  
  160.   if(pos = FindBrokerTask(task))
  161.   {
  162.    set(LV_Broker, MUIA_List_Active, pos);
  163.    DoMethod(LV_Broker, MUIM_List_Jump, pos);
  164.  
  165.    return(RETURN_OK);
  166.   }
  167.  }
  168.  
  169.  return(RETURN_ERROR);
  170. }
  171.  
  172. void __saveds __asm MouseFunc(register __a2 Object *Help, register __a1 Object **Obj)
  173. {
  174.  LONG udata = NULL;
  175.  
  176.  if(*Obj)
  177.   get(*Obj, MUIA_UserData, &udata);
  178.  
  179.  set(TX_Desc, MUIA_Text_Contents, udata);
  180. }
  181.  
  182. struct Hook MouseHook         = { {NULL, NULL}, (void *)MouseFunc,         NULL, NULL };
  183. struct Hook SelectNameRXHook  = { {NULL, NULL}, (void *)SelectNameRXFunc,  NULL, NULL };
  184. struct Hook SelectTaskRXHook  = { {NULL, NULL}, (void *)SelectTaskRXFunc,  NULL, NULL };
  185. struct Hook BrokerListConHook = { {NULL, NULL}, (void *)BrokerListConFunc, NULL, NULL };
  186. struct Hook BrokerListDesHook = { {NULL, NULL}, (void *)BrokerListDesFunc, NULL, NULL };
  187. struct Hook BrokerListDspHook = { {NULL, NULL}, (void *)BrokerListDspFunc, NULL, NULL };
  188. struct Hook BrokerListCmpHook = { {NULL, NULL}, (void *)BrokerListCmpFunc, NULL, NULL };
  189. struct Hook BrokerListBrkHook = { {NULL, NULL}, (void *)BrokerListBrkFunc, NULL, NULL };
  190.  
  191. struct NewMenu MenuList[] =
  192. {
  193.  { NM_TITLE,    "",                0,    0,    0,    0            },
  194.  { NM_ITEM,    "",                "?",    0,    0,    (APTR) ID_ABOUT        },
  195.  { NM_ITEM,    NM_BARLABEL,            0,    0,    0,    0            },
  196.  { NM_ITEM,    "",                "I",    0,    0,    (APTR) ID_ICONIFY    },
  197.  { NM_ITEM,    "",                "Q",    0,    0,    (APTR) ID_QUIT        },
  198.  
  199.  { NM_TITLE,    "",                0,    0,    0,    0            },
  200.  { NM_ITEM,    "",                "A",    0,    0,    (APTR) ID_ACTIVATE    },
  201.  { NM_ITEM,    "",                "D",    0,    0,    (APTR) ID_DEACTIVATE    },
  202.  { NM_ITEM,    "",                "R",    0,    0,    (APTR) ID_REMOVE    },
  203.  
  204.  { NM_ITEM,    "",                0,    0,    0,    (APTR) ID_ACTIVATESEL   },
  205.  { NM_ITEM,    "",                0,    0,    0,    (APTR) ID_DEACTIVATESEL    },
  206.  { NM_ITEM,    "",                0,    0,    0,    (APTR) ID_REMOVESEL    },
  207.  
  208.  { NM_ITEM,    "",                "C",    0,    0,    (APTR) ID_ACTIVATEALL    },
  209.  { NM_ITEM,    "",                "L",    0,    0,    (APTR) ID_DEACTIVATEALL    },
  210.  { NM_ITEM,    "",                0,    0,    0,    (APTR) ID_REMOVEALL    },
  211.  
  212.  { NM_ITEM,    NM_BARLABEL,            0,    0,    0,    0            },
  213.  { NM_ITEM,    "",                0,    0,    0,    0            },
  214.  { NM_SUB,    "",                "S",    0,    0,    (APTR) ID_SHOW        },
  215.  { NM_SUB,    "",                0,    0,    0,    (APTR) ID_SHOWSEL    },
  216.  { NM_SUB,    "",                "H",    0,    0,    (APTR) ID_HIDE        },
  217.  { NM_SUB,    "",                0,    0,    0,    (APTR) ID_HIDESEL    },
  218.  
  219.  { NM_END,    NULL,                0,    0,    0,    0            }
  220. };
  221.  
  222. struct MUI_Command ARexxList[] =
  223. {
  224.  { "select_name",    "NAME/A",        1,            &SelectNameRXHook},
  225.  { "select_task",    "TASKADR/N/A",        1,            &SelectTaskRXHook},
  226.  
  227.  { "activate",        MC_TEMPLATE_ID,        ID_ACTIVATE,        NULL},
  228.  { "deactivate",    MC_TEMPLATE_ID,        ID_DEACTIVATE,        NULL},
  229.  { "activatesel",    MC_TEMPLATE_ID,        ID_ACTIVATESEL,        NULL},
  230.  { "deactivatesel",    MC_TEMPLATE_ID,        ID_DEACTIVATESEL,    NULL},
  231.  { "activateall",    MC_TEMPLATE_ID,        ID_ACTIVATEALL,        NULL},
  232.  { "deactivateall",    MC_TEMPLATE_ID,        ID_DEACTIVATEALL,    NULL},
  233.  { "remove",        MC_TEMPLATE_ID,        ID_REMOVE,        NULL},
  234.  { "removeall",        MC_TEMPLATE_ID,        ID_REMOVEALL,        NULL},
  235.  { "removesel",        MC_TEMPLATE_ID,        ID_REMOVESEL,        NULL},
  236.  
  237.  { "interface_show",    MC_TEMPLATE_ID,        ID_SHOW,        NULL},
  238.  { "interface_hide",    MC_TEMPLATE_ID,        ID_HIDE,        NULL},
  239.  { "interface_showsel",    MC_TEMPLATE_ID,        ID_SHOWSEL,        NULL},
  240.  { "interface_hidesel",    MC_TEMPLATE_ID,        ID_HIDESEL,        NULL},
  241.  
  242.  { NULL,            NULL,        0,            NULL}
  243. };
  244.  
  245.  
  246. static char *dedication = "Dedicated to Caruso";
  247.  
  248. UWORD ExChangeSleepImg1Data[] =
  249. {
  250.  0x0003,0x8000,0x0000,0x0000,0x0004,0x4000,0x0000,0x0000,
  251.  0x0008,0x4000,0x0000,0x0000,0x0018,0x4de0,0x0000,0x0000,
  252.  0x0020,0x3210,0x0000,0x0000,0x0020,0x0008,0x0000,0x0000,
  253.  0x0020,0x0008,0x0000,0x0000,0x0020,0xf008,0x0000,0x0000,
  254.  0x0020,0x2788,0x0000,0x0000,0x0010,0x4108,0x0000,0x0000,
  255.  0x0010,0xf208,0x0000,0x0000,0x0008,0x0790,0x0000,0x0000,
  256.  0x0008,0x0020,0x0000,0x0000,0x003c,0x00c0,0x0000,0x0400,
  257.  0x0046,0x3f00,0x0000,0x0c00,0x0083,0xe008,0x0000,0x0c00,
  258.  0x0100,0x8038,0x0000,0x0c00,0x0101,0x00fc,0x0000,0x0c00,
  259.  0x0386,0x03fc,0x0000,0x0c00,0x04c8,0x0ff0,0x0000,0x0c00,
  260.  0x08b0,0x3ffc,0xc180,0x2c00,0x0500,0xffc0,0x6300,0x4c00,
  261.  0x0203,0xfd80,0x363c,0x8c00,0x000f,0xf180,0x1c41,0x0c00,
  262.  0x003f,0xc180,0x1c42,0x0c00,0x00ff,0x0180,0x3640,0x0c00,
  263.  0x03fc,0x00c0,0x6340,0x0c00,0x03f0,0x003c,0xc180,0x0c00,
  264.  0x01c0,0x0000,0x0080,0x0c00,0x0102,0x0000,0x0100,0x0c00,
  265.  0x0001,0x0000,0x0600,0x0c00,0x0000,0x9fff,0xf800,0x0c00,
  266.  0x0000,0x6000,0x0000,0x0c00,0x0000,0x2000,0x0000,0x0c00,
  267.  0x7fff,0xffff,0xffff,0xfc00,0x0003,0x8000,0x0000,0x0000,
  268.  0x0007,0xc000,0x0000,0x0000,0x000f,0xc000,0x0000,0x0000,
  269.  0x001f,0xcde0,0x0000,0x0000,0x003f,0xfff0,0x0000,0x0000,
  270.  0x003f,0xfff8,0x0000,0x0000,0x003f,0xfff8,0x0000,0x0000,
  271.  0x003f,0x0ff8,0x0000,0x0000,0x003f,0xd878,0x0000,0x0000,
  272.  0x001f,0xbef8,0x0000,0x0000,0x001f,0x0df8,0x0000,0x0000,
  273.  0x000f,0xf870,0x0000,0x0000,0x000f,0xffe0,0x0000,0x0000,
  274.  0xffff,0xffff,0xffff,0xf800,0xd57f,0xff51,0x5552,0x5000,
  275.  0xd5ff,0xf55f,0x8003,0x5000,0xd5ff,0xd527,0xbfff,0x9000,
  276.  0xd5ff,0x5482,0x7fff,0xd000,0xd7ff,0x5205,0xffff,0xe000,
  277.  0xd7fd,0x4813,0xffff,0xf000,0xdff5,0x2043,0x3e7f,0xd000,
  278.  0xd754,0x813f,0x9cff,0x9000,0xd752,0x047f,0xc9c3,0x5000,
  279.  0xd548,0x107e,0x2392,0x5000,0xd520,0x607e,0x2391,0x5000,
  280.  0xd481,0x3e7f,0xc995,0x5000,0xd204,0xff3f,0x9c95,0x5000,
  281.  0xc413,0xffc3,0x3e55,0x5000,0xde47,0xffff,0xff55,0x5000,
  282.  0xbf11,0xffff,0xfe55,0x5000,0xd854,0xffff,0xf955,0x5000,
  283.  0xc555,0x6000,0x0555,0x5000,0xd555,0x1555,0x5555,0x5000,
  284.  0xd555,0x5555,0x5555,0x5000,0x8000,0x0000,0x0000,0x0000,
  285. };
  286.  
  287. struct Image ExChangeSleepImg1 =
  288. {
  289.  0x0000,0x0000,0x0036,0x0023,0x0002,
  290.  &ExChangeSleepImg1Data[0],
  291.  0x03,0x00,0x00000000,
  292. };
  293.  
  294. struct DiskObject ExchangeSleepDObj =
  295. {
  296.  0xe310,0x0001,
  297.  0x00000000,
  298.  0x00db,0x0050,0x0036,0x0024,0x0004,0x0003,0x0001,
  299.  (APTR)&ExChangeSleepImg1,NULL,
  300.  0x00000000,0x00000000,0x00000000,
  301.  0x0000,
  302.  0x00000000,
  303.  0x0003,
  304.  0x00000000,0x00000000,0x80000000,0x80000000,
  305.  0x00000000,0x00000000,0x00000000,
  306. };
  307.  
  308. struct DiskObject *ExchangeDObj;
  309.  
  310. BOOL SetUpTimer(void)
  311. {
  312.  if(TPort = CreateMsgPort())
  313.  {
  314.   TSignal = (1L << TPort -> mp_SigBit);
  315.  
  316.   if(TRequest = CreateIORequest(TPort, sizeof(struct timerequest)))
  317.   {
  318.    if(!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)TRequest, 0))
  319.    {
  320.     TRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  321.     TRequest -> tr_time . tv_secs    = 1;
  322.     TRequest -> tr_time . tv_micro    = 0;
  323.  
  324.     SendIO((struct IORequest *)TRequest);
  325.  
  326.     return(TRUE);
  327.    }
  328.    DeleteIORequest(TRequest);
  329.   }
  330.   DeleteMsgPort(TPort);
  331.  }
  332.  
  333.  return(FALSE);
  334. }
  335.  
  336. void CloseTimer(void)
  337. {
  338.  if(!(CheckIO((struct IORequest *)TRequest)))
  339.   AbortIO((struct IORequest *)TRequest);
  340.  
  341.  WaitIO((struct IORequest *)TRequest);
  342.  CloseDevice((struct IORequest *)TRequest);
  343.  
  344.  DeleteIORequest(TRequest);
  345.  
  346.  while(GetMsg(TPort))
  347.   ;
  348.  
  349.  DeleteMsgPort(TPort);
  350. }
  351.  
  352. LONG FindBrokerTask(ULONG t)
  353. {
  354.  struct BrokerCopy *bc;
  355.  LONG i;
  356.  
  357.  for(i=0;;i++)
  358.  {
  359.   DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  360.  
  361.   if(!bc)
  362.    break;
  363.  
  364.   if(bc -> bc_Task == t)
  365.    return(i);
  366.  }
  367.  
  368.  return(-1);
  369. }
  370.  
  371. LONG FindBrokerName(char *n)
  372. {
  373.  struct BrokerCopy *bc;
  374.  register int i;
  375.  
  376.  for(i=0;;i++)
  377.  {
  378.   DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  379.  
  380.   if(!bc)
  381.    break;
  382.  
  383.   if(stricmp(&bc -> bc_Name[0], n) == 0)
  384.    return((LONG)i);
  385.  }
  386.  
  387.  return(-1);
  388. }
  389.  
  390. void SetObjects(void)
  391. {
  392.  struct BrokerCopy *bc;
  393.  register int i;
  394.  ULONG entries;
  395.  LONG state;
  396.  BOOL ende = FALSE;
  397.  
  398.  BOOL activate_able = TRUE, disable_interface = TRUE;
  399.  BOOL disable_activate_sel = TRUE, disable_interface_sel = TRUE;
  400.  
  401.  DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  402.  
  403.  if(bc)
  404.  {
  405.   if(bc -> bc_Flags & COF_SHOW_HIDE)
  406.    disable_interface = FALSE;
  407.  
  408.   if(!(bc -> bc_Flags & COF_ACTIVE))
  409.    activate_able = FALSE;
  410.  }
  411.  
  412.  get(LV_Broker, MUIA_List_Entries, &entries);
  413.  
  414.  for(i=0; i < entries; i++)
  415.  {
  416.   DoMethod(LV_Broker, MUIM_List_Select, i, MUIV_List_Select_Ask, &state);
  417.  
  418.   if(state)
  419.   {
  420.    disable_activate_sel = FALSE;
  421.    DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  422.  
  423.    if(!bc)
  424.     ende = TRUE;
  425.  
  426.    if(bc -> bc_Flags & COF_SHOW_HIDE)
  427.     disable_interface_sel = FALSE;
  428.   }
  429.  
  430.   if(ende)
  431.    break;
  432.  }
  433.  
  434.  if(set_able != activate_able)
  435.  {
  436.   SetAttrs(BT_Toggle, MUIA_NoNotify, TRUE, MUIA_Cycle_Active, activate_able ? 0 : 1, TAG_DONE);
  437.   set_able = activate_able;
  438.  }
  439.  
  440.  set(BT_Show,       MUIA_Disabled, disable_interface);
  441.  set(BT_Hide,       MUIA_Disabled, disable_interface);
  442.  
  443.  set(BT_ActSel,    MUIA_Disabled, disable_activate_sel);
  444.  set(BT_RemoveSel, MUIA_Disabled, disable_activate_sel);
  445.  set(BT_DeActSel,  MUIA_Disabled, disable_activate_sel);
  446.  set(BT_ShowSel,   MUIA_Disabled, disable_interface_sel);
  447.  set(BT_HideSel,   MUIA_Disabled, disable_interface_sel);
  448.  
  449.  
  450.  DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_ACTIVATE,   activate_able);
  451.  DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_DEACTIVATE, !activate_able);
  452.  
  453.  DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_INTERFACE, !disable_interface);
  454. }
  455.  
  456. void SetInfoText(void)
  457. {
  458.  struct BrokerCopy *bc;
  459.  UBYTE Buffer[600];
  460.  
  461.  DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  462.  
  463.  sprintf(Buffer, "\0334%s\n\n\0330%s", bc -> bc_Title, bc -> bc_Descr);
  464.  set(FT_Info, MUIA_Floattext_Text, Buffer);
  465. }
  466.  
  467. RefreshBrokerList()
  468. {
  469.  static UBYTE count;
  470.  
  471.  struct List *BrokerList;
  472.  ULONG i;
  473.  struct BrokerCopy *bc;
  474.  
  475.  if(BrokerList = AllocVec(sizeof(struct List), MEMF_PUBLIC))
  476.  {
  477.   struct Node *n, *nn;
  478.   LONG pos, curs;
  479.  
  480.   count++;
  481.  
  482.   NewList(BrokerList);
  483.  
  484.   CopyBrokerList(BrokerList);
  485.  
  486.   get(LV_Broker, MUIA_List_Active, &curs);
  487.  
  488.   n = BrokerList->lh_Head;
  489.  
  490.   while (n && (nn = n->ln_Succ))
  491.   {
  492.    if((pos = FindBrokerName((char *)&((struct BrokerCopy *)n)->bc_Name[0])) >= 0)
  493.    {
  494.     DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  495.  
  496.     bc -> bc_Flags          = ((struct BrokerCopy *)n)->bc_Flags;
  497.     bc -> bc_Node . ln_Type = count;
  498.  
  499.     if(curs == pos)
  500.      SetObjects();
  501.    }
  502.    else
  503.    {
  504.     ((struct BrokerCopy *) n) -> bc_Node.ln_Type = count;
  505.     DoMethod(LV_Broker, MUIM_List_Insert, &n, 1, MUIV_List_Insert_Sorted);
  506.    }
  507.  
  508.    n = nn;
  509.   }
  510.  
  511.   FreeBrokerList(BrokerList);
  512.   FreeVec(BrokerList);
  513.  
  514.   for (i=0; ; i++)
  515.   {
  516.    DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  517.  
  518.    if (!bc)
  519.     break;
  520.  
  521.    if (bc->bc_Node.ln_Type != count)
  522.     DoMethod(LV_Broker, MUIM_List_Remove, i--);
  523.   }
  524.  }
  525.  return(TRUE);
  526. }
  527.  
  528. MakeMUI()
  529. {
  530.  UBYTE *Screen = ArgString(TTypes, "PUBSCREEN", "Workbench");
  531.  
  532.  if(AP_ExChange = ApplicationObject,
  533.             MUIA_HelpFile,         "ExChange.guide",
  534.            MUIA_Application_Title,     "ExChange",
  535.            MUIA_Application_Version,     "$VER: Exchange "VERSION" ("__DATE__")",
  536.            MUIA_Application_Copyright,     "© 1994-95 by T.O.M. Software",
  537.            MUIA_Application_Author,     "Marc-Christian Schröer",
  538.            MUIA_Application_Description, GetExchangeString(AppDescription),
  539.            MUIA_Application_Base,     "EXCH",
  540.            MUIA_Application_Menu,     MenuList,
  541.            MUIA_Application_Commands,     ARexxList,
  542.            MUIA_Application_BrokerHook,     &BrokerListBrkHook,
  543.            MUIA_Application_SingleTask,     TRUE,
  544.            MUIA_Application_DiskObject,     ExchangeDObj,
  545.  
  546.            SubWindow, WN_Main = WindowObject,
  547.                      MUIA_HelpNode, "GADGETS",
  548.                      MUIA_Window_PublicScreen, Screen,
  549.                      MUIA_Window_ID, "MAIN",
  550.                      MUIA_Window_Title, "Exchange "VERSION" - © 1994-95 by Marc-Christian Schröer",
  551.                      MUIA_Window_NeedsMouseObject,    TRUE,
  552.                      WindowContents, VGroup,
  553.                               Child, HGroup,
  554.                                   Child, LV_Broker = ListviewObject,
  555.                                                 MUIA_Weight, 80,
  556.                                               MUIA_Listview_DoubleClick, TRUE,
  557.                                               MUIA_Listview_MultiSelect, MUIV_Listview_MultiSelect_Default,
  558.                                               MUIA_Listview_List, ListObject,
  559.                                                             InputListFrame,
  560.                                                                 MUIA_FrameTitle,        GetExchangeString(CommList),
  561.                                                                             MUIA_List_ConstructHook,    &BrokerListConHook,
  562.                                                                  MUIA_List_DestructHook,    &BrokerListDesHook,
  563.                                                                     MUIA_List_CompareHook,    &BrokerListCmpHook,
  564.                                                                    MUIA_List_DisplayHook,    &BrokerListDspHook,
  565.                                                                    MUIA_List_Format,        "P=\0332,P=\0333\033r",
  566.                                                                    MUIA_List_Title,        TRUE,
  567.                                                                   End,
  568.                                              End,
  569.                                   Child, VGroup,
  570.                                         MUIA_Weight, 20,
  571.                                       Child, FT_Info = ListviewObject,
  572.                                                 MUIA_Listview_List, FloattextObject,
  573.                                                                 TextFrame,
  574.                                                                   MUIA_FrameTitle, GetExchangeString(FrameInfo),
  575.                                                                  MUIA_Floattext_Text, "",
  576.                                                                 End,
  577.                                                 MUIA_Listview_Input,FALSE,
  578.                                                       End,
  579.                                       Child, RegisterGroup(Pages),
  580.                                            MUIA_Register_Frame, TRUE,
  581.                                               Child, HGroup,
  582.                                                     MUIA_Group_SameWidth, TRUE,
  583.                                                     MUIA_Group_Columns, 2,
  584.                                               Child, BT_Show   = MUI_MakeObject(MUIO_Button, GetExchangeString(GadShowInterface)),
  585.                                                       Child, BT_Hide   = MUI_MakeObject(MUIO_Button, GetExchangeString(GadHideInterface)),
  586.                                               Child, BT_Toggle = KeyCycle(CycleEntries, *GetExchangeString(GadActivateKey)),
  587.                                               Child, BT_Remove = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemove)),
  588.                                              End,
  589.                                               Child, VGroup,
  590.                                                       Child, HGroup,
  591.                                                         MUIA_Group_SameWidth, TRUE,
  592.                                                         MUIA_Group_Columns, 2,
  593.                                                   Child, BT_ShowSel   = MUI_MakeObject(MUIO_Button, GetExchangeString(GadShowInterfaceSel)),
  594.                                                           Child, BT_HideSel   = MUI_MakeObject(MUIO_Button, GetExchangeString(GadHideInterfaceSel)),
  595.                                                   Child, BT_ActSel    = MUI_MakeObject(MUIO_Button, GetExchangeString(GadActivateSel)),
  596.                                                   Child, BT_DeActSel  = MUI_MakeObject(MUIO_Button, GetExchangeString(GadDeActivateSel)),
  597.                                                  End,
  598.                                               Child, BT_RemoveSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemoveSel)),
  599.                                              End,
  600.                                               Child, HGroup,
  601.                                                     MUIA_Group_SameWidth, TRUE,
  602.                                                     MUIA_Group_Columns, 1,
  603.                                               Child, BT_ActAll    = MUI_MakeObject(MUIO_Button, GetExchangeString(GadActivateAll)),
  604.                                                       Child, BT_DeActAll  = MUI_MakeObject(MUIO_Button, GetExchangeString(GadDeActivateAll)),
  605.                                                       Child, BT_RemoveAll = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemoveAll)),
  606.                                              End,
  607.                                              End,
  608.                                      Child, HGroup,
  609.                                              MUIA_Group_SameWidth, TRUE,
  610.                                          Child, BT_Icon    = MUI_MakeObject(MUIO_Button, GetExchangeString(GadIconify)),
  611.                                                    Child, BT_Quit    = MUI_MakeObject(MUIO_Button, GetExchangeString(GadQuit)),
  612.                                         End,
  613.                                         End,
  614.                                        End,
  615.  
  616.                                 Child, HGroup,
  617.                                        Child, MUI_MakeObject(MUIO_Label, GetExchangeString(GadDesc), 0),
  618.                                          Child, TX_Desc = TextObject,
  619.                                                MUIA_Text_PreParse, "\0333",
  620.                                                MUIA_InnerLeft, 0,
  621.                                                MUIA_InnerRight, 0,
  622.                                                ReadListFrame,
  623.                                               End,
  624.                                        End,
  625.                                      End,
  626.                     End,
  627.           End)
  628.  {
  629.   DoMethod(WN_Main, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, AP_ExChange, 2, MUIM_Application_ReturnID, ID_ICONIFY);
  630.  
  631.   DoMethod(LV_Broker,    MUIM_Notify, MUIA_Listview_SelectChange, TRUE, AP_ExChange, 2, MUIM_Application_ReturnID, ID_LV_ACTIVE);
  632.   DoMethod(LV_Broker,    MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, AP_ExChange, 2, MUIM_Application_ReturnID, ID_LV_ACTIVE);
  633.   DoMethod(LV_Broker,    MUIM_Notify, MUIA_Listview_DoubleClick, TRUE,  AP_ExChange, 2, MUIM_Application_ReturnID, ID_DOUBLE);
  634.   DoMethod(AP_ExChange, MUIM_Notify, MUIA_Application_MenuHelp, MUIV_EveryTime, AP_ExChange, 2, MUIM_Application_ReturnID, ID_MENUHELP);
  635.   DoMethod(WN_Main, MUIM_Notify, MUIA_Window_MouseObject, MUIV_EveryTime, TX_Desc, 3, MUIM_CallHook, &MouseHook, MUIV_TriggerValue);
  636.  
  637.   SetCycID(AP_ExChange, BT_Toggle,    ID_TOGGLE);
  638.   SetButID(AP_ExChange, BT_Remove,     ID_REMOVE);
  639.   SetButID(AP_ExChange, BT_Hide,     ID_HIDE);
  640.   SetButID(AP_ExChange, BT_Show,     ID_SHOW);
  641.  
  642.   SetButID(AP_ExChange, BT_DeActAll,     ID_DEACTIVATEALL);
  643.   SetButID(AP_ExChange, BT_ActAll,     ID_ACTIVATEALL);
  644.   SetButID(AP_ExChange, BT_RemoveAll,     ID_REMOVEALL);
  645.  
  646.   SetButID(AP_ExChange, BT_ActSel,    ID_ACTIVATESEL);
  647.   SetButID(AP_ExChange, BT_DeActSel,     ID_DEACTIVATESEL);
  648.   SetButID(AP_ExChange, BT_RemoveSel,     ID_REMOVESEL);
  649.   SetButID(AP_ExChange, BT_HideSel,     ID_HIDESEL);
  650.   SetButID(AP_ExChange, BT_ShowSel,     ID_SHOWSEL);
  651.  
  652.   SetButID(AP_ExChange, BT_Icon,     ID_ICONIFY);
  653.   SetButID(AP_ExChange, BT_Quit,     ID_QUIT);
  654.  
  655.   set(FT_Info,        MUIA_UserData, GetExchangeString(DescInfo));
  656.   set(LV_Broker,    MUIA_UserData, GetExchangeString(DescBroker));
  657.   set(BT_Toggle,    MUIA_UserData, GetExchangeString(DescToggle));
  658.   set(BT_Remove,    MUIA_UserData, GetExchangeString(DescRemove));
  659.   set(BT_Show,        MUIA_UserData, GetExchangeString(DescShow));
  660.   set(BT_Hide,        MUIA_UserData, GetExchangeString(DescHide));
  661.   set(BT_DeActAll,    MUIA_UserData, GetExchangeString(DescDeActAll));
  662.   set(BT_ActAll,    MUIA_UserData, GetExchangeString(DescActAll));
  663.   set(BT_Icon,        MUIA_UserData, GetExchangeString(DescIcon));
  664.   set(BT_Quit,        MUIA_UserData, GetExchangeString(DescQuit));
  665.   set(BT_RemoveAll,    MUIA_UserData, GetExchangeString(DescRemoveAll));
  666.   set(BT_ActSel,    MUIA_UserData, GetExchangeString(DescActSel));
  667.   set(BT_DeActSel,    MUIA_UserData, GetExchangeString(DescDeActSel));
  668.   set(BT_RemoveSel,    MUIA_UserData, GetExchangeString(DescRemoveSel));
  669.   set(BT_ShowSel,    MUIA_UserData, GetExchangeString(DescShowSel));
  670.   set(BT_HideSel,    MUIA_UserData, GetExchangeString(DescHideSel));
  671.   set(TX_Desc,        MUIA_UserData, GetExchangeString(DescDesc));
  672.  
  673.   DoMethod(WN_Main, MUIM_Window_SetCycleChain, LV_Broker, FT_Info, BT_Toggle, BT_Remove, BT_Hide, BT_Show, BT_ActAll, BT_DeActAll, BT_RemoveAll, BT_Icon, BT_Quit, NULL);
  674.  
  675.   return(TRUE);
  676.  }
  677.  return(FALSE);
  678. }
  679.  
  680. void About()
  681. {
  682.  MUI_Request(AP_ExChange, WN_Main, 0, "ExChange Info", "*Ok", GetExchangeString(InfoText));
  683. }
  684.  
  685. BOOL SetUpBroker()
  686. {
  687.  CxObj          *MyBroker, *Sender, *Hotkey, *Translate;
  688.  struct MsgPort *BrokerPort;
  689.  
  690.  get(AP_ExChange, MUIA_Application_Broker, &MyBroker);
  691.  get(AP_ExChange, MUIA_Application_BrokerPort, &BrokerPort);
  692.  
  693.  SetCxObjPri(MyBroker, ArgInt(TTypes, "CX_PRIORITY", 0));
  694.  
  695.  if(Hotkey = CxFilter(ArgString(TTypes, "CX_POPKEY", "alt help")))
  696.  {
  697.   AttachCxObj(MyBroker, Hotkey);
  698.  
  699.   if(Sender = CxSender(BrokerPort, ID_HOTKEY))
  700.   {
  701.    AttachCxObj(Hotkey, Sender);
  702.  
  703.    if(Translate = CxTranslate(NULL))
  704.    {
  705.     AttachCxObj(Hotkey, Translate);
  706.     return(TRUE);
  707.    }
  708.   }
  709.   DeleteCxObj(Hotkey);
  710.  }
  711.  
  712.  return(FALSE);
  713. }
  714.  
  715. void SetUpMenus()
  716. {
  717.  MenuList[0]  . nm_Label   = GetExchangeString(MenuProject);
  718.  MenuList[1]  . nm_Label   = GetExchangeString(MenuProjectAbout);
  719.  MenuList[3]  . nm_Label   = GetExchangeString(MenuProjectIconify);
  720.  MenuList[4]  . nm_Label   = GetExchangeString(MenuProjectQuit);
  721.  MenuList[5]  . nm_Label   = GetExchangeString(MenuBroker);
  722.  MenuList[6]  . nm_Label   = GetExchangeString(MenuBrokerActivate);
  723.  MenuList[7]  . nm_Label   = GetExchangeString(MenuBrokerDeActivate);
  724.  MenuList[8]  . nm_Label   = GetExchangeString(MenuBrokerRemove);
  725.  MenuList[9]  . nm_Label   = GetExchangeString(MenuBrokerActivateSel);
  726.  MenuList[10] . nm_Label   = GetExchangeString(MenuBrokerDeActivateSel);
  727.  MenuList[11] . nm_Label   = GetExchangeString(MenuBrokerRemoveSel);
  728.  MenuList[12] . nm_Label   = GetExchangeString(MenuBrokerActivateAll);
  729.  MenuList[13] . nm_Label   = GetExchangeString(MenuBrokerDeActivateAll);
  730.  MenuList[14] . nm_Label   = GetExchangeString(MenuBrokerRemoveSel);
  731.  MenuList[16] . nm_Label   = GetExchangeString(MenuBrokerInterface);
  732.  MenuList[17] . nm_Label   = GetExchangeString(MenuBrokerInterfaceShow);
  733.  MenuList[18] . nm_Label   = GetExchangeString(MenuBrokerInterfaceShowSel);
  734.  MenuList[19] . nm_Label   = GetExchangeString(MenuBrokerInterfaceHide);
  735.  MenuList[20] . nm_Label   = GetExchangeString(MenuBrokerInterfaceHideSel);
  736.  
  737.  Pages[0] = GetExchangeString(GroupSingle);
  738.  Pages[1] = GetExchangeString(GroupSelected);
  739.  Pages[2] = GetExchangeString(GroupAll);
  740.  Pages[3] = NULL;
  741.  
  742.  CycleEntries[0] = GetExchangeString(GadDeActivate);
  743.  CycleEntries[1] = GetExchangeString(GadActivate);
  744.  CycleEntries[2] = NULL;
  745. }
  746.  
  747. int main(int argc, UBYTE **argv)
  748. {
  749.  ULONG signals, retsignals, running = TRUE, pos;
  750.  struct BrokerCopy *bc;
  751.  register int i;
  752.  char *IconfileName;
  753.  
  754.  if(IconBase = OpenLibrary("icon.library",0))
  755.  {
  756.   ExchangeDObj = &ExchangeSleepDObj;
  757.  
  758.   LocaleBase = OpenLibrary("locale.library",0);
  759.   OpenExchangeCatalog(NULL, NULL);
  760.  
  761.   if(CxBase = OpenLibrary("commodities.library",0))
  762.   {
  763.    TTypes = ArgArrayInit(argc, argv);
  764.  
  765.    AppIcon = (!stricmp((char *)ArgString(TTypes, "APPICON", "ON"), "ON"));
  766.  
  767.    if(strlen(IconfileName = ArgString(TTypes, "ICONFILE", "")))
  768.    {
  769.     if(stricmp(strrchr((char *)IconfileName, '.'),".info") == 0)
  770.      *strrchr((char *)IconfileName, '.') = 0x00;
  771.  
  772.     if(!(ExchangeDObj = GetDiskObject(IconfileName)))
  773.      ExchangeDObj = &ExchangeSleepDObj;
  774.    }
  775.  
  776. // for some strange reasons, this does not work
  777.  
  778.    ExchangeDObj -> do_CurrentX = ArgInt(TTypes, "ICONPOS_X", NO_ICON_POSITION);
  779.    ExchangeDObj -> do_CurrentY = ArgInt(TTypes, "ICONPOS_Y", NO_ICON_POSITION);
  780.    ExchangeDObj -> do_Type = 0;
  781.  
  782.    if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))
  783.    {
  784.     if(MUIMasterBase = OpenLibrary("muimaster.library",0))
  785.     {
  786.      if(SetUpTimer())
  787.      {
  788.       SetUpMenus();
  789.  
  790.       if(MakeMUI())
  791.       {
  792.        if(SetUpBroker())
  793.        {
  794.         RefreshBrokerList();
  795.         SetObjects();
  796.         SetInfoText();
  797.  
  798.         set(LV_Broker, MUIA_List_Active, 0);
  799.  
  800.         if(strnicmp((char *)ArgString(TTypes, "CX_POPUP", "YES"), "Y", 1))
  801.         {
  802.          if(AppIcon)
  803.          {
  804.           set(AP_ExChange, MUIA_Application_Iconified, TRUE);
  805.           set(WN_Main, MUIA_Window_Open, TRUE);
  806.          }
  807.         }
  808.         else
  809.         {
  810.          set(WN_Main, MUIA_Window_Open, TRUE);
  811.          set(WN_Main, MUIA_Window_ActiveObject, LV_Broker);
  812.         }
  813.  
  814.         while(running)
  815.         {
  816.          switch(DoMethod(AP_ExChange, MUIM_Application_Input, &signals))
  817.          {
  818.       case ID_MENUHELP:    DoMethod(AP_ExChange, MUIM_Application_ShowHelp, NULL, "ExChange.guide", "MENUS", 0);
  819.                 break;
  820.  
  821.           case ID_ABOUT:    About();
  822.                 break;
  823.  
  824.           case ID_LV_ACTIVE:    SetObjects();
  825.                 SetInfoText();
  826.                 break;
  827.  
  828.       case ID_TOGGLE:    DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  829.  
  830.                 if(bc -> bc_Flags & COF_ACTIVE)
  831.                 {
  832.                   bc -> bc_Flags &= ~COF_ACTIVE;
  833.                   BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
  834.                 }
  835.                 else
  836.                 {
  837.                   bc -> bc_Flags |= COF_ACTIVE;
  838.                   BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
  839.                 }
  840.                 SetObjects();
  841.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
  842.                 break;
  843.  
  844.       case ID_ACTIVATESEL:  for(pos = -1;pos != -1;)
  845.                 {
  846.                  DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
  847.  
  848.                  if(pos == -1)
  849.                   break;
  850.  
  851.                  DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  852.                  BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
  853.                 }
  854.                 RefreshBrokerList();
  855.                 SetObjects();
  856.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
  857.                 break;
  858.  
  859.       case ID_DEACTIVATESEL:for(pos = -1;pos != -1;)
  860.                 {
  861.                  DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
  862.  
  863.                  if(pos == -1)
  864.                   break;
  865.  
  866.                  DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  867.                  BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
  868.                 }
  869.                 SetObjects();
  870.                 RefreshBrokerList();
  871.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
  872.                 break;
  873.  
  874.       case ID_SHOWSEL:    for(pos = -1;pos != -1;)
  875.                 {
  876.                  DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
  877.  
  878.                  if(pos == -1)
  879.                   break;
  880.  
  881.                  DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  882.                  BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
  883.                 }
  884.                 break;
  885.  
  886.       case ID_HIDESEL:    for(pos = -1;pos != -1;)
  887.                 {
  888.                  DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
  889.  
  890.                  if(pos == -1)
  891.                   break;
  892.  
  893.                  DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  894.                  BrokerCommand(bc -> bc_Name, CXCMD_DISAPPEAR);
  895.                 }
  896.                 break;
  897.  
  898.  
  899.       case ID_REMOVESEL:    for(pos = -1;pos != -1;)
  900.                 {
  901.                  DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
  902.  
  903.                  if(pos == -1)
  904.                   break;
  905.  
  906.                  DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
  907.                  BrokerCommand(bc -> bc_Name, CXCMD_KILL);
  908.                 }
  909.                 SetObjects();
  910.                 RefreshBrokerList();
  911.                 break;
  912.  
  913.       case ID_DEACTIVATE:    DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  914.                 BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
  915.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
  916.                 break;
  917.  
  918.       case ID_ACTIVATE:    DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  919.                 BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
  920.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
  921.                 break;
  922.  
  923.       case ID_DEACTIVATEALL:for(i=0;;i++)
  924.                 {
  925.                  DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  926.  
  927.                  if(!bc)
  928.                   break;
  929.  
  930.                  BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
  931.                 }
  932.                 SetObjects();
  933.                 RefreshBrokerList();
  934.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
  935.                 break;
  936.  
  937.       case ID_ACTIVATEALL:    for(i=0;;i++)
  938.                 {
  939.                  DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  940.  
  941.                  if(!bc)
  942.                   break;
  943.  
  944.                  BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
  945.                 }
  946.                 SetObjects();
  947.                 RefreshBrokerList();
  948.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
  949.                 break;
  950.  
  951.       case ID_REMOVEALL:    for(i=0;;i++)
  952.                 {
  953.                  DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
  954.  
  955.                  if(!bc)
  956.                   break;
  957.  
  958.                  BrokerCommand(bc -> bc_Name, CXCMD_KILL);
  959.                 }
  960.                 SetObjects();
  961.                 RefreshBrokerList();
  962.                 DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
  963.                 break;
  964.  
  965.       case ID_REMOVE:    DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  966.                 BrokerCommand(bc -> bc_Name, CXCMD_KILL);
  967.                 break;
  968.  
  969.       case ID_SHOW:        DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  970.                  BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
  971.                 break;
  972.  
  973.       case ID_DOUBLE:    DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  974.                 if(bc -> bc_Flags & COF_SHOW_HIDE)
  975.                  BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
  976.                 break;
  977.  
  978.       case ID_HIDE:        DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
  979.                 BrokerCommand(bc -> bc_Name, CXCMD_DISAPPEAR);
  980.                 break;
  981.  
  982.       case ID_ICONIFY:    if(AppIcon)
  983.                  set(AP_ExChange, MUIA_Application_Iconified, TRUE);
  984.                 else
  985.                  set(WN_Main, MUIA_Window_Open, FALSE);
  986.                 break;
  987.           case ID_QUIT:
  988.           case MUIV_Application_ReturnID_Quit:     running = FALSE;
  989.                         break;
  990.          }
  991.  
  992.          if(running && signals)
  993.           retsignals = Wait(signals | TSignal);
  994.  
  995.          if(retsignals & TSignal)
  996.          {
  997.           while(GetMsg(TPort))
  998.            ;
  999.  
  1000.       RefreshBrokerList();
  1001.  
  1002.       TRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  1003.       TRequest -> tr_time . tv_secs        = 1;
  1004.       TRequest -> tr_time . tv_micro    = 0;
  1005.  
  1006.       SendIO((struct IORequest *)TRequest);
  1007.      }
  1008.         }
  1009.        }
  1010.  
  1011.        MUI_DisposeObject(AP_ExChange);
  1012.       }
  1013.  
  1014.       CloseTimer();
  1015.      }
  1016.      CloseLibrary((struct Library *)MUIMasterBase);
  1017.      ArgArrayDone();
  1018.     }
  1019.     CloseLibrary((struct Library *)IntuitionBase);
  1020.    }
  1021.    CloseLibrary((struct Library *)CxBase);
  1022.  
  1023.    if(ExchangeDObj != &ExchangeSleepDObj)
  1024.     if(ExchangeDObj)
  1025.      FreeDiskObject(ExchangeDObj);
  1026.   }
  1027.  
  1028.   if(LocaleBase) CloseLibrary(LocaleBase);
  1029.  
  1030.   CloseExchangeCatalog();
  1031.   CloseLibrary(IconBase);
  1032.  }
  1033. }
  1034.